package com.wdl.sm.webui.security;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("suserService")
public class SUserService {
    @Autowired
    private SUserRepository repository;

    public List<SUser> findAll() {
        return repository.findAll();
    }
    
    public SUser create(SUser user) {
        return repository.save(user);
    }

    public SUser update(SUser user) {
        return repository.save(user);
    }

    public void delete(String id) {
        repository.delete(id);
    }

    public SUser findUserByName(String name) {
        return repository.findByName(name);
    }

    public SUser findUserByEmail(String email) {
        return repository.findByEmail(email);
    }

    public SUser login(String name, String password) {
        return repository.findByNameAndPassword(name, password);
    }
}
